package main

import (
	"fmt"
	"sync"
)

var a []int
var b chan int //指定通道元素的类型

var wg sync.WaitGroup

func noBufChannel() {
	fmt.Println(b)
	b = make(chan int)
	wg.Add(1)
	go func() {
		defer wg.Done()
		x := <-b
		fmt.Println("进去的是个啥", x)
	}()
	b <- 10
	fmt.Println("放入b中")
	wg.Wait()
}

func BufChannel() {
	b = make(chan int, 16)
	fmt.Println(b)
	b <- 10
	b <- 20
	fmt.Println("放入b中")
	x := <-b
	fmt.Println("进去的是个啥", x)
	close(b)
}

func main() {

	BufChannel()

}
